﻿namespace WMS6.Web.Administration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class InMessageQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnSearch;
        protected DropDownList ddlCreatedDate;
        protected DropDownList ddlFromUserID;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlIsRead;
        protected DropDownList ddlIsReadOper;
        protected DropDownList ddlMessageTitle;
        protected DropDownList ddlSystemCreate;
        protected DropDownList ddlSystemCreateOper;
        protected HtmlForm F1223;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img2;
        protected Label lblCreatedDate;
        protected Label lblFromUserID;
        protected Label lblIsActive;
        protected Label lblIsRead;
        protected Label lblMessageTitle;
        protected Label lblSystemCreate;
        protected Label lblUserInMessage;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCreatedDate;
        protected TextBox txtCreatedDate2;
        protected TextBox txtFromUserID;
        protected TextBox txtMessageTitle;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InMessageList.aspx?action={0}&from='list'", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InMessageList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnExport.Visible = false;
                this.hdnActionID.Value = base.Request.QueryString["action"];
            }
        }

        private void LoadDLL()
        {
            base.InitQueryDDL(this.ddlMessageTitle, 0);
            base.InitQueryDDL(this.ddlCreatedDate, 1);
            base.InitQueryDDL(this.ddlFromUserID, 0);
            base.InitQueryDDL(this.ddlIsReadOper, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitQueryDDL(this.ddlSystemCreateOper, 0);
            base.InitIsActiveDDL(this.ddlSystemCreate, 0);
            base.InitIsActiveDDL(this.ddlIsRead, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 1);
            this.ddlIsActive.SelectedValue = "N";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDLL();
                this.LoadData();
            }
        }

        public string CreatedDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedDate.Text.Trim(), this.ddlCreatedDate.SelectedValue, this.txtCreatedDate2.Text.Trim(), "CreatedDate");
                }
                return "";
            }
        }

        public string FromUserID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtFromUserID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtFromUserID.Text.Trim(), this.ddlFromUserID.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string IsRead
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsRead.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsRead.SelectedValue, this.ddlIsReadOper.SelectedValue);
                }
                return "";
            }
        }

        public string MessageTitle
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtMessageTitle.Text.Trim()))
                {
                    return base.GetParamsString(this.txtMessageTitle.Text.Trim(), this.ddlMessageTitle.SelectedValue);
                }
                return "";
            }
        }

        public string SystemCreated
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlSystemCreate.SelectedValue))
                {
                    return base.GetParamsString(this.ddlSystemCreate.SelectedValue, this.ddlSystemCreateOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

